package onlinebanking.server;

import java.io.IOException;

import javax.swing.SwingUtilities;

import onlinebanking.server.gui.AdministratorFrame;

/**
 * The class that opens the server
 * @author Edgar
 *
 */
public class BankServer {
	private static SimpleServer server;
	private static AdministratorFrame admin;

	/**
	 * Runs the server.
	 * @param args Command-line arguments
	 */
	public static void main(String[] args) {
//		BankServer.admin = new AdministratorFrame();
		
		try {
			javax.swing.UIManager
					.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
		} catch (Exception e) {
			e.printStackTrace();
		}

		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				BankServer.admin = new AdministratorFrame();
				BankServer.admin.setLocationRelativeTo(null);
				BankServer.admin.setVisible(true);
				
				try {
					BankServer.server = SimpleServer.getInstance(BankServer.admin);
					
					BankServer.admin.bind(BankServer.server);
//					BankServer.server = SimpleServer.getInstance();
					
					System.out.println("observers: " + BankServer.server.countObservers());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		});
		

	}
}
